package cn.qingyun.gis.modules.baogan.controller;

import cn.qingyun.gis.common.Result;
import cn.qingyun.gis.modules.baogan.service.MicrogridCareRecordService;
import cn.qingyun.gis.modules.baogan.vo.request.HasCarePointInAddWktRequest;
import cn.qingyun.gis.modules.baogan.vo.request.MicroGridCareRecordAddOrUpdateRequest;
import cn.qingyun.gis.modules.baogan.vo.request.MicroGridCareRecordSaveOrUpdateBatchRequest;
import cn.qingyun.gis.modules.baogan.vo.request.StreetCareRecordSaveOrUpdateRequest;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author sgc
 * @date 2024年11月14日 8:45
 */
@RestController
@Slf4j
@RequestMapping("/microgrid/care/record")
public class MicrogridCareRecordController {

    @Autowired
    private MicrogridCareRecordService microgridCareRecordService;

    @ApiOperation("微网格-看管划分-新增或修改")
    @PostMapping("/saveOrUpdateMicroGrid")
    public Result<?> saveOrUpdateMicroGrid(@Validated @RequestBody MicroGridCareRecordSaveOrUpdateBatchRequest request) {
        microgridCareRecordService.saveOrUpdateMicroGrid(request);
        return Result.ok();
    }

    @ApiOperation("点、沿街及绘制面-看管划分-新增或修改")
    @PostMapping("/saveOrUpdateStreet")
    public Result<?> saveOrUpdateStreet(@Validated @RequestBody StreetCareRecordSaveOrUpdateRequest request) {
        microgridCareRecordService.saveOrUpdateStreet(request);
        return Result.ok();
    }

    @ApiOperation("查询新增的面中是否存在已有人员包干的点")
    @PostMapping("/hasCarePointInAddWkt")
    public Result<?> hasCarePointInAddWkt(@Validated @RequestBody HasCarePointInAddWktRequest request) {
        boolean result = microgridCareRecordService.hasCarePointInAddWkt(request);
        return Result.okData(result);
    }

}
